package com.halden.TRPG.service.impl;

import com.halden.TRPG.common.CodeEnum;
import com.halden.TRPG.entity.vo.InitRoomVo;
import com.halden.TRPG.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InitRoomServiceImpl implements InitRoomService {

    @Autowired
    private RoomImageService roomImageService;

    @Autowired
    private RoomNicknameService roomNicknameService;

    @Autowired
    private RoomService roomService;

    @Autowired
    private MessageService messageService;

    @Autowired
    private RoomFileService roomFileService;

    @Override
    public CodeEnum initRoom(Long rid, String uid, Long start, Long length) {
        InitRoomVo vo = new InitRoomVo();
        vo.setImages(roomImageService.getImages(rid).getData());
        vo.setNickName(roomNicknameService.getNicknameString(rid,uid));
        vo.setOwnerUid(roomService.getById(rid).getOwnerUid());
        vo.setDarkDiceMessages(messageService.getDarkDiceMessage(rid).getData());
        vo.setMessageList(messageService.getMessage(uid,rid,start,length).getData());
        vo.setFileList(roomFileService.getFileList(rid).getData());
        return CodeEnum.SUCCESS.setData(vo);
    }
}
